<div class="tblsitebox">
	<div class='right'>
		<a href='/tasklets?fmt=yaml'>导出[yaml]</a>
		||
		<a href='/tasklet/import'>导入</a>
	</div>
</div>


<div class="tblsitebox">
	<h3 class="tblsitename">[任务集] <%= @current_project ? @current_project.name : '' %></h3>
	<h4>列表 | <a href="#">矩阵</a> | <a href="<%= @current_project ? @current_project.link + '?gantt=true' : '/tasklets?gantt=true' %>" class="colorbox cbGantt">Gantt</a></h4>
	<table cellpadding="0" cellspacing="0" width="100%" class="tblsite"> 
		<tbody class="tblsite-bd">
			<tr>
				<td>ID</td>
				<td>标题</td>
				<td>说明</td>
				<td>进度</td>
			</tr>

<% @tasks.each do |task| %>
			<tr>
				<td class="URGENT_<%=task.urgent%> IMPORTANT_<%=task.important%> FINISHED_<%=task.finished?%>"><%=task.id%></td>
				<td class="URGENT_<%=task.urgent%> IMPORTANT_<%=task.important%> FINISHED_<%=task.finished?%>"><%=task.link_tag(task.name, {:class => 'colorbox cbTasklet'})%></td>
				<td>[ <%= task.created_at.strftime("%F %T") %>
				- <%= task.due.strftime("%F %T") %> ]<br />
					<%= task.description %>
				</td>
				<td><%= task.finished? ? "#{task.user ? task.user.name : 'unknown'}<br />完成于 #{(task.updated_at ? task.updated_at : task.finished_at).strftime('%F %T')}" : "未完成" %></td>

			</tr>
<% end %>
		</tbody>
	</table>
</div>

<div class="tblsitebox">
	<form action="/tasklet/create" method="POST">
		<fieldset>
			<legend>新增任务</legend>
			<select name='project_id'>
			<% @projects.each do |project| %>
				<option value="<%=project.id%>" <%=(@current_project and @current_project.id == project.id) ? 'selected' : '' %>><%=project.name%></option>
			<% end %>
			</select>
			<input type='text' name='name' size='24' />
			[
			<input type='radio' name='important' value=1 id='important_high'><label for='important_high'>重要</label>
			<input type='radio' name='important' value=0 id='important_low' checked><label for='important_low'>普通</label>
			] [
			<input type='radio' name='urgent' value=1 id='urgent_high'><label for='urgent_high'>紧急</label>
			<input type='radio' name='urgent' value=0 id='urgent_low' checked><label for='urgent_low'>一般</label>
			]
			<br />

			<textarea cols="72" rows="4" name='description'></textarea>
			<br />

			<label>期望日期</label>
			<input type="date" name="due" value='<%=(Time.now+86400).strftime("%F %T") %>' />
			<input type="hidden" name="user_id" value=<%=@current_user.id%> />

			<input style="float: right;" type='submit' value='创建任务'>
		</fieldset>
	</form>
</div>
